package com.gxa.eshops.sso.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
 * @program: IntelliJ IDEA
 * @description:
 * @author: Mr.Wang
 * @create: 2022-07-05 16:13
 **/
@Data
@Entity
@Table(name = "tb_user")
public class User implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "user_id")
    private Long id;
    @Column(name = "user_name")
    private String name;
    @Column(name = "user_phone",unique = true)
    private String phone;
    @Column(name = "user_password")
    @JsonIgnore
    private String password;
    @Column(name = "salt")
    @JsonIgnore
    private String salt;
    /**
     * 登录类型: 1.手机网页端 2.pc网页端 3.手机app端
     */
    @Column(name="login_type")
    @JsonIgnore
    private Integer loginType;
    /**
     * 用户状态 1.正常 2.禁用
     */
    @Column(name="user_status")
    @JsonIgnore
    private Integer status;

    /**
     * 最后一次登录的时间
     */
    @Column(name="last_login_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime lastLoginTime;
    /**
     * 手机端刷新token
     */
    @Column(name="token")
    @JsonIgnore
    private String token;
    /**
     * 记录用户连接时的IP地址
     */
    @Column(name="ip_address")
    @JsonIgnore
    private String ipAddress;

}
